<template>
  <div style="width: 100%;">
    <div class="search-content">
      <div class="search-list">
        <slot></slot>
      </div>
        <!-- <div class="showOrHide" @click="toggleFlag = !toggleFlag">{{ toggleFlag?'展开':'收起' }}</div> -->
      <div class="search-btn" :class="{toggleFlag: toggleFlag}">
        <!-- <div class="showOrHide" @click="reloads">
          <div>{{ '刷新' }}</div>
        </div> -->
        <div class="searchBtn">
          <img src="~@/assets/action-bar-icon/search.png" @click="search" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  inject: ["reload"],
  data() {
    return {
      toggleFlag: false, // false: 展开 true: 收起
      searchStyle: {
        height: 0,
        padding: 0,
        overflow: 'hidden'
      }
    };
  },
  methods: {
    packUp () {
      if (this.searchStyle) {
        this.searchStyle = null
      } else {
        this.searchStyle = {
          height: 0,
          padding: 0,
          overflow: 'hidden'
        }
      }
    },
    search() {
      this.$emit("search");
    },
    reloads() {
      this.reload();
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~@/styles/variables.scss";
.search-content {
  position: relative;
  display: flex;
  justify-content: space-between;
}

.search-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 100%;
  justify-content: flex-start;
  align-content: flex-start;
  ::v-deep .seach-box {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;

    .select-box-content {
      padding: 5px 15px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      color: #c1cfd2;
      font-size: 16px;
      // .select-box-content-name {
      //   // width: 140px;
      // }

      .select-box-content-nameA {
        width: 160px;
      }

      .select-box-content-all {
        cursor: pointer;
        padding: 0 10px 0 0;

        &:hover {
          font-weight: 600;
          color: #54dee2;
        }
      }

      .select-box-content-list {
        cursor: pointer;
        padding: 0 20px 0 0;

        &:hover {
          font-weight: 600;
          color: #54dee2;
        }
      }

      .select-box-content-list-time {
        cursor: pointer;
        padding: 0 10px;

        &:hover {
          font-weight: 600;
          color: #54dee2;
        }
      }

      > .el-input {
        width: 200px;
        margin: 0 10px;
      }

      > .el-cascader {
        width: 200px;
        margin: 0 10px;
      }

      > .el-date-editor {
        margin: 0 10px;
      }
    }
  }
  ::v-deep .common-search-item {
    margin-bottom: 5px;
    margin-top: 5px;
    width: 22%;
    max-width: 32%;
    margin-right: 1px;
    margin-left: 1px;
    .label {
      width: auto !important;
      min-width: 80px !important;
      text-align: end;
    }
    .input {
      width: 80%;
    }
    // ::v-deep {
    .el-select {
      width: 100%;
    }
    .el-cascader {
      width: 100%;
    }
    .el-date-editor {
      width: 100%;
    }
    // }
  }
  // 时间 长框适用
  ::v-deep .common-search-items {
    margin-bottom: 5px;
    margin-top: 5px;
    width: 43%;
    max-width: 64%;
    .label {
      width: auto !important;
      min-width: 80px !important;
      text-align: end;
    }
    .input {
      width: 80%;
    }
    // ::v-deep {
    .el-select {
      width: 100%;
    }
    .el-cascader {
      width: 100%;
    }
    .el-date-editor {
      width: 100%;
    }
    // }
  }
  ::v-deep .common-search-itemx {
    margin-bottom: 5px;
    margin-top: 5px;
    width: 33%;
    max-width: 64%;
    .label {
      width: auto !important;
      min-width: 80px !important;
      text-align: end;
    }
    .input {
      width: 80%;
    }
    // ::v-deep {
    .el-select {
      width: 100%;
    }
    .el-cascader {
      width: 100%;
    }
    .el-date-editor {
      width: 100%;
    }
    // }
  }
  &.toggleFlag {
    flex-direction: row;
    flex-wrap: nowrap;
    ::v-deep .common-search-item {
      margin-right: 10px;
      &:nth-child(n + 4) {
        margin-top: 10px;
        display: none;
      }
    }
    ::v-deep .common-search-items {
      margin-right: 10px;
      &:nth-child(n + 8) {
        margin-top: 10px;
        display: none;
      }
    }
  }
}
.search-btn {
  width: 160px;
  flex-shrink: 0;
  margin-left: 20px;
  // display: flex;
  // align-items: center;
  position: relative;
  &.toggleFlag {
    display: flex;
    align-items: center;
    width: 120px;
    .searchBtn {
      margin-top: 0;
      margin-left: 10px;
    }
  }
  .showOrHide {
    margin-top: 7px;
    background-color: rgb(72, 214, 146);
    border-radius: 4px;
    height: 32px;
    width: 70px;
    cursor: pointer;
    text-align: center;
    font-size: 16px;
    position: absolute;
    right: 80px;
    padding-top: 2.5px;
    div {
      padding-top: 3px;
      text-align: center;
      font-size: 16px;
      display: inline-block;
      width: 64px;
      height: 26px;
      background-color: rgb(72, 214, 146);
      box-shadow: 0px 0px 2px 2px rgba(0, 0, 0, 0.4);
      border-radius: 4px;
      opacity: 1;
    }
    &:hover {
      transform: scale(1.05);
    }
  }
  .searchBtn {
    margin: 0px auto 0;
    position: absolute;
    top: 7px;
    right: 7px;
    // margin: 10px auto 0;
    img {
      display: block;
      margin: 0 auto;
    }
  }
}
</style>
